<?php
$this->LoadHelper('ApiHelper');
$ApiHelper = new ApiHelper();

$this->LoadHelper('MemberHelper');
$MemberHelper = new MemberHelper();

$this->LoadHelper('PublicHelper');
$PublicHelper = new PublicHelper();

$this->LoadHelper('SmsHelper');
$SmsHelper = new SmsHelper();

$check = $ApiHelper->tokenCheck($this->Param);
if(!$check['success']) ErrorMsg::ApiMsg($check['msg'], $check['code']);

switch ($this->Param['option']){
    case 'pwdsubmit':        
        $member_info = $MemberHelper->getMemberRow($this->Param['uid']);
        if(empty($member_info)){
            ErrorMsg::ApiMsg('无当前用户信息');
        }
        $u_repassword = empty($this->Param['u_repassword']) ? ErrorMsg::ApiMsg('请输入密码') : $this->Param['u_repassword'];
        $code = empty($this->Param['u_code']) ? ErrorMsg::ApiMsg('请输入验证码') : $this->Param['u_code'];
        $sms_verify = $SmsHelper->smsVerify($member_info['u_mobile'], $code);
        if($sms_verify){
            $data = array();            
            $member_info['u_salt'] = StringCode::RandomCode(6);
            $member_info['u_password'] = md5(md5($u_repassword).$member_info['u_salt']);
            $uid = $member_info['u_id'];
            unset($member_info['u_id']);
            $MemberHelper->memberSave($member_info, $uid);
            $ApiHelper->logSave('changepwd', $this->Param);
            ErrorMsg::ApiMsg('密码修改成功', 0);
        }else{
            ErrorMsg::ApiMsg('验证码校验失败');
        }
        break;
    default :
        break;
}